# Maintainer: prspkt <prspkt@protonmail.com>
pkgname=py3-werkzeug
_pkgname=werkzeug
pkgver=3.0.6
pkgrel=0
pkgdesc="The WSGI swiss-army knife"
url="https://werkzeug.palletsprojects.com/"
arch="noarch"
license="MIT"
depends="python3 py3-markupsafe"
makedepends="py3-gpep517 py3-flit-core"
checkdepends="py3-pytest py3-requests py3-pytest-timeout"
subpackages="$pkgname-pyc"
source="https://files.pythonhosted.org/packages/source/${_pkgname:0:1}/$_pkgname/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

replaces="py-werkzeug" # Backwards compatibility
provides="py-werkzeug=$pkgver-r$pkgrel" # Backwards compatibility

# secfixes:
#   2.2.2-r0:
#     - CVE-2022-29361
#   2.3.7-r0:
#     - CVE-2023-46136
#   3.0.6-r0:
#     - CVE-2024-49767

prepare() {
	default_prepare
	# requires ephemeral-port-preserve
	rm -fv tests/conftest.py
	rm -fv tests/test_debug.py
	# requires various pytest plugins
	rm -fv tests/test_serving.py
	rm -fv tests//middleware/test_http_proxy.py
}

build() {
	gpep517 build-wheel \
		--wheel-dir .dist \
		--output-fd 3 3>&1 >&2
}

check() {
	python3 -m venv --clear --without-pip --system-site-packages .testenv
	.testenv/bin/python3 -m installer .dist/*.whl
	.testenv/bin/python3 -m pytest
}

package() {
	python3 -m installer -d "$pkgdir" \
		.dist/*.whl
}

sha512sums="
500f47e13546a3d0ce3a41f21157649571ea70b332ca22758bad939cb42aee4d1b58b64cecc4ed83a857ad466f37de8256cf7b53ad28e5fe0fd353455df3639b  werkzeug-3.0.6.tar.gz
"
